package com.longrise.android.byjk.plugins.dealsituation.course.video2.params;

import java.util.Arrays;


/**
 * Created by godliness on 2017/5/19.
 * 当前课件全部信息
 */

public final class StudyRecordBase {

    private static Record mRecord;

    private static StudyState mStudyState;

    private StudyRecordBase() {

    }

    public static Record getRecordInstance() {
        if (mRecord == null) {
            synchronized (StudyRecordBase.class) {
                if (mRecord == null) {
                    mRecord = new Record();
                }
            }
        }
        return mRecord;
    }

    public static StudyState getStudyStateInstance() {
        if (mStudyState == null) {
            synchronized (StudyRecordBase.class) {
                if (mStudyState == null) {
                    mStudyState = new StudyState();
                }
            }
        }
        return mStudyState;
    }

    /**
     * 内部类单例模式 内存中只会存在一份
     * 方法之间传递使用
     */
    public static class Record {

        private Record() {
        }

        public void init() {
            mCourseid = null;
            mCwid = null;
            mPathno = null;
            mStudentno = null;
            mId = null;
            mUploaded = false;
            mPosition = 0;
            mDuration = 0;
        }

        /**
         * 课件所在课程id  每个课程唯一id
         */
        public String mCourseid;

        /**
         * 课件id
         */
        public String mCwid;

        /**
         * 课件配置路径
         */
        public String mPathno;

        /**
         * 学号  每个课程唯一学号
         */
        public String mStudentno;

        /**
         * 学习记录id
         */
        public String mId;

        /**
         * 是否具备同步学习记录条件 如果该值为true 说明该课件已经学习过，但是同步记录失败
         */
        public boolean mUploaded = false;

        /**
         * 当前进度
         */
        public int mPosition;

        /**
         * 总时长
         */
        public int mDuration;

        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("Record{");
            sb.append("mCourseid='").append(mCourseid).append('\'');
            sb.append(", mCwid='").append(mCwid).append('\'');
            sb.append(", mPathno='").append(mPathno).append('\'');
            sb.append(", mStudentno='").append(mStudentno).append('\'');
            sb.append(", mId='").append(mId).append('\'');
            sb.append(", mUploaded=").append(mUploaded);
            sb.append(", mPosition=").append(mPosition);
            sb.append(", mDuration=").append(mDuration);
            sb.append('}');
            return sb.toString();
        }
    }

    /**
     * 内部类单例模式 内存中只会存在一份
     * 方法之间传递使用
     */
    public static class StudyState {

        private StudyState() {
        }

        public void init() {
            mIsFinish = false;
            mVideoPass = false;
            mHasqa = false;
            mCwidName = null;
            mCwidLocal = null;
            cwidStyle = null;
        }

        /**
         * 课件是否完成
         */
        public boolean mIsFinish;

        /**
         * 课件是否通过
         */
        public boolean mVideoPass;

        /**
         * 课件是否有课后习题
         */
        public boolean mHasqa;

        /**
         * 课件名字
         */
        public String mCwidName;

        /**
         * 长度为2 {group, child}
         */
        public int[] mCwidLocal;

        /**
         * 课件类型
         */
        public String cwidStyle;

        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("StudyState{");
            sb.append("mIsFinish=").append(mIsFinish);
            sb.append(", mVideoPass=").append(mVideoPass);
            sb.append(", mHasqa=").append(mHasqa);
            sb.append(", mCwidName='").append(mCwidName).append('\'');
            sb.append(", mCwidLocal=").append(Arrays.toString(mCwidLocal));
            sb.append('}');
            return sb.toString();
        }
    }
}
